package Mike.RegExp;

import java.util.regex.*;

public class RegResult {
	public static Pattern pattern;
	public static Matcher matcher;
	public RegResult(String patterns,String matchers){
		pattern = Pattern.compile(patterns);
		matcher = pattern.matcher(matchers);
	}
	public static String RegExpResult(String patterns,String matchers){
		pattern = Pattern.compile(patterns);
		matcher = pattern.matcher(matchers);
		matcher.find(0);
		return matcher.group();
	}
	public String getResult(){
		matcher.find(0);
		return matcher.group();
	}
	public String[] getResultArray(){
		String[] ans=new String[matcher.groupCount()];
		for(int i=0;i<matcher.groupCount();i++){
			matcher.find();
			ans[i]=matcher.group();
		}
		return ans;
	}
	public static void main(String[] args) {
		System.out.println(RegResult.RegExpResult("[0-9,[,]]*[.][0-9,[,]]*", "123,,87,,.63,,24,290."));
		System.out.println(RegResult.RegExpResult("[0-9]*[.][0-9][0-9]", "2131.00"));
	}
}
